<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>编辑班级 - ${bean.name }</title>
<c:import url="/WEB-INF/jsp/head.jsp" />
<script type="text/javascript">
	//保存当前已选择的教师Id
	var teacherIds = [];
	<c:forEach items="${bean.teachers }" var="item">
		teacherIds.push(${item.id});
	</c:forEach>
	<c:forEach items="${bean.instructors }" var="item">
		teacherIds.push(${item.id});
	</c:forEach>
</script>
<script type="text/javascript" src="static/js/class/edit.js"></script>
<c:import url="/WEB-INF/jsp/plugin/bootstrap-table.jsp" />
<c:import url="/WEB-INF/jsp/plugin/datetimepicker.jsp" />
<script type="text/javascript" src="static/js/bootbox.4.4.0.min.js"></script>
<style type="text/css">
.table th, .table td {
	text-align: center;
	vertical-align: middle !important;
}
</style>
</head>
<body>
	<div class="default-theme container-fluid iframe">
		<div class="col-md-8">
			<form id="class-form" class="form-horizontal" action="class/edit"
				method="post">
				<div class="form-group">
					<label for="name" class="col-sm-2 control-label"><i
						class="text-danger">*</i> 班级名称</label>
					<div class="col-sm-10">
						<input type="hidden" name="name" value="${bean.name }" /> <input
							type="text" class="form-control" readonly="readonly"
							placeholder="班级名称" value="${bean.name }">
					</div>
				</div>
				<div class="form-group">
					<label for="product.id" class="col-sm-2 control-label"><i
						class="text-danger">*</i> 产品</label>
					<div class="col-sm-10">
						<select class="form-control" name="product.id">
							<c:forEach items="${products }" var="item">
								<option value="${item.id }"
									<c:if test="${item.id == bean.product.id }">selected="selected"</c:if>>${item.name }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label for="teacherName" class="col-sm-2 control-label"><i
						class="text-danger">*</i> 教员</label>
					<div class="col-sm-10">
						<table class="table table-hover table-border">
							<thead>
								<tr>
									<th>教师编号</th>
									<th>教师名称</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${bean.teachers }" var="item">
									<tr>
										<td>${item.id }</td>
										<td>${item.name }</td>
										<td><input type='hidden' name="teacherIds"
											value="${item.id }" />
											<button data-type="del" data-id="${item.id }" type='button'
												class='btn-xs btn-link'>删除</button></td>
									</tr>
								</c:forEach>
								<tr>
									<td colspan="3">
										<button data-type="add" type="button" class="btn-xs btn-link"
											data-toggle="modal" data-target="#teacherSelect"
											data-teacher-type="1">新增教员</button>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>
				<div class="form-group">
					<label for="tel" class="col-sm-2 control-label"><i
						class="text-danger">*</i> 辅导员</label>
					<div class="col-sm-10">
						<table class="table table-hover table-border">
							<thead>
								<tr>
									<th>教师编号</th>
									<th>教师名称</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${bean.instructors }" var="item">
									<tr>
										<td>${item.id }</td>
										<td>${item.name }</td>
										<td><input type='hidden' name="teacherIds"
											value="${item.id }" />
											<button data-type="del" data-id="${item.id }" type='button'
												class='btn-xs btn-link'>删除</button></td>

									</tr>
								</c:forEach>
								<tr>
									<td colspan="3">
										<button data-type="add" type="button" class="btn-xs btn-link"
											data-toggle="modal" data-target="#teacherSelect"
											data-teacher-type="2">新增辅导员</button>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>
				<div class="form-group">
					<label for="tel" class="col-sm-2 control-label">预科时间</label>
					<div class="col-sm-10">
						<input type="text" class="form-control date"
							name="preparatoryDate" readonly="readonly" placeholder="预科时间"
							value="<fmt:formatDate pattern="yyyy-MM-dd" value="${bean.preparatoryDate }" />" />
					</div>
				</div>
				<div class="form-group">
					<label for="openDate" class="col-sm-2 control-label">正课时间</label>
					<div class="col-sm-10">
						<input type="text" class="form-control date" name="openDate"
							readonly="readonly" placeholder="正课时间"
							value="<fmt:formatDate pattern="yyyy-MM-dd" value="${bean.openDate }" />" />
					</div>
				</div>
				<div class="form-group">
					<label for="trainDate" class="col-sm-2 control-label">实训时间</label>
					<div class="col-sm-10">
						<input class="form-control date" name="trainDate"
							readonly="readonly" placeholder="实训时间"
							value="<fmt:formatDate pattern="yyyy-MM-dd" value="${bean.trainDate }" />" />
					</div>
				</div>
				<div class="form-group">
					<label for="endDate" class="col-sm-2 control-label">毕业时间</label>
					<div class="col-sm-10">
						<input class="form-control date" name="endDate"
							readonly="readonly" placeholder="毕业时间"
							value="<fmt:formatDate pattern="yyyy-MM-dd" value="${bean.endDate }" />" />
					</div>
				</div>
				<div class="form-group">
					<label for="endDate" class="col-sm-2 control-label"></label>
					<div class="col-sm-10">
						<i class="text-danger">填写毕业时间后，班级状态将会自动更改为结课状态，且不能修改</i>
					</div>
				</div>
				<div class="form-group">
					<label for="remarks" class="col-sm-2 control-label">备注</label>
					<div class="col-sm-10">
						<textarea class="form-control" name="remarks" placeholder="备注">${bean.remarks }</textarea>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-offset-2 col-sm-10">
						<button type="submit" class="btn btn-primary">提交</button>
						<!-- <a href="javascript:history.back();" class="btn btn-default">返回</a> -->
					</div>
				</div>
				<input type="hidden" name="className" value="${className }" /> <input
					type="hidden" name="productId" value="${productId }" /> <input
					type="hidden" name="classStatus" value="${classStatus }"> <input
					type="hidden" name="pageNum" value="${pageNum }" /> <input
					type="hidden" name="pageSize" value="${pageSize }" />
			</form>
			<div class="modal fade" id="teacherSelect" tabindex="-1"
				role="dialog">
				<div class="modal-dialog" role="document">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal"
								aria-label="Close">
								<span aria-hidden="true">&times;</span>
							</button>
							<h4 class="modal-title">选择教师</h4>
						</div>
						<div class="modal-body form-inline" style="overflow: hidden;">
							<div class="col-md-12">
								<div class="panel panel-default">
									<div class="panel-heading">搜索条件</div>
									<div class="panel-body">
										<div class="form-group">
											<label for="type.value">教师姓名：</label> <input type="text"
												class="form-control" id="teacherName" />
										</div>
										<input type="hidden" id="teacherType" />
										<button class="selectTeacher btn btn-default">搜索</button>
									</div>
								</div>
							</div>
							<div class="col-md-12">
								<table id="teacherForm" class="table table-hover table-border"></table>
							</div>
						</div>
						<div class="modal-footer">
							<button class="btn btn-default" data-dismiss="modal">关闭</button>
						</div>
					</div>
				</div>
			</div>
			<div class="modal fade" id="error" tabindex="-1" role="dialog">
				<div class="modal-dialog" role="document">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal"
								aria-label="Close">
								<span aria-hidden="true">&times;</span>
							</button>
							<h4 class="modal-title">提示</h4>
						</div>
						<div class="modal-body form-inline" style="overflow: hidden;">
							<div class="col-md-12">至少选择一名教师</div>
						</div>
						<div class="modal-footer">
							<button class="btn btn-default" data-dismiss="modal">关闭</button>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>